# - Vim formatting with fo=t or fo=a can mess up SnipMate.
#                       t :  Auto-wrap text using textwidth
#                               a   Automatic formatting of paragraphs.    *auto-format*  *autoformat* *fo-a*
#                                   Every time text is inserted or  deleted the paragraph will be reformatted.
#                                   When the 'c' flag is present this only happens for recognized  comments.

# 语法
# snippet trigger    optional description
#     expanded text
#     more expanded text


# snippet header standard Vim script file header
#     " File: ${1:`expand('%:t')`}
#     " Author: ${2:`g:snips_author`}
#     " Description: ${3}
#     ${0:" Last Modified: `strftime("%B %d, %Y")`}


snippet guard script reload guard
	if exists('${1:did_`vim_snippets#Filename()`}') || &cp${2: || version < 700}
		finish
	endif
	let $1 = 1${0}


# expand('%') =~ 'autoload' ?
#     substitute(matchstr(expand('%:p'),'autoload/\zs.*\ze.vim'),'[/\\]','#','g').'#'
#     : ''

snippet f function
	fun! ${1:Name}(${3})
		${0}
	endf


snippet fu function
	fun! ${1:`expand('%') =~ 'autoload' ? substitute(matchstr(expand('%:p'),'autoload/\zs.*\ze.vim'),'[/\\]','#','g').'#' : ''`}${2:Name}(${3})
		${0}
	endf


snippet t    try ... catch statement
	try
		${1:${VISUAL}}
	catch ${2}
		${0}
	endtry

snippet tr    try ... catch statement
	try
		${1:${VISUAL}}
	catch ${2}
		${0}
	endtry


snippet for for ... in loop
	for ${1} in ${2}
		${0:${VISUAL}}
	endfor

snippet forkv for [key, value] in loop
	for [${1},${2}] in items(${3})
		${0}
		unlet $1 $2
	endfor

snippet wh while loop
	while ${1}
		${0:${VISUAL}}
	endw

snippet if if statement
	if ${1}
		${0:${VISUAL}}
	endif

snippet ife if ... else statement
	if ${1}
		${2:${VISUAL}}
	else
		${0}
	endif


snippet au 我的autocmd
    au AG

snippet a 我的autocmd
    au AG


snippet p vim-plug Plugin definition
	PL '${0}'

# snippet plugdo vim-plug Plugin definition with { 'do': '' }
#     Plug '${1}', { 'do': '${0}' }
# snippet plugon vim-plug Plugin definition with { 'on': '' }
#     Plug '${1}', { 'on': '${0}' }
# snippet plugfor vim-plug Plugin definition with { 'for': '' }
#     Plug '${1}', { 'for': '${0}' }
# snippet plugbr vim-plug Plugin definition with { 'branch': '' }
#     Plug '${1}', { 'branch': '${0}' }
# snippet plugtag vim-plug Plugin definition with { 'tag': '' }
#     Plug '${1}', { 'tag': '${0}' }


snippet l
let ${1:var} = ${0: value}
# snippet s
#     set ${1:setting}=${0:value}

snippet c
<Cmd>${1:_cmd}<cr>

# map function
snippet mf
nno ${1} <Cmd>call ${2}()<cr>


# <Cmd>${1:cmd}<cr>${1}
# snippet nn
#     nnoremap ${1} ${2}<CR>
# snippet no
#     noremap ${1} ${2}
# snippet vm
#     vmap ${1} ${2}
# snippet im
#     imap ${1} ${2}
# snippet exe
#     execute ${1}
# snippet filename
#     `Filename()`

snippet ca    call a function
    call ${1:F}()${0:<cr>}

